package com.nuaa.dao.change.impl;

import java.util.Date;

import javax.transaction.Transactional;

import org.springframework.stereotype.Repository;

import com.nuaa.dao.base.impl.BaseDaoImpl;
import com.nuaa.dao.change.inter.ChangeDaoInter;
import com.nuaa.domain.change.ChangeEntity;
import com.nuaa.utils.AjaxMsg;
import com.nuaa.utils.CustomCodeUtil;
/**
 * 换标订单Dao
 * @author heaven
 *
 */
@Repository("changeDao")
public class ChangeDaoImpl extends BaseDaoImpl<ChangeEntity, Integer> implements ChangeDaoInter{
	/**保存一条订单信息*/
	@Override
	@Transactional
	public AjaxMsg saveOrder(ChangeEntity entity) {
		AjaxMsg msg = new AjaxMsg();
		try{
			String CH_NO = CustomCodeUtil.getChangeOrderNo(this.getMaxId(entity.getClass()));
			entity.setOrder_no(CH_NO);
			entity.setBusiness_type("FBA换标业务");
			entity.setCreate_tm(new Date());
			this.save(entity);
			msg.setSuccess(true);
			msg.setResult(CH_NO);
			msg.setMsg("提交成功！");
		}catch(Exception e){
			msg.setSuccess(false);
			msg.setMsg("提交失败！");
		}
		return msg;
	}
}
